package com.gitee.wsl.ext.string

/**
 * Extracts from a string the char sequence of length `size` that occurs after the given subsequence.
 *
 * @param str  the string
 * @param seq  the subsequence to search
 * @param size the number of chars to extract
 * @return the extracted substring, or an empty string if the subsequence is not found
 */
fun String.afterSequence( seq: String, size: Int): String {
    val idx = indexOf(seq) + seq.length
    if (idx == 0) {
        return ""
    }
    return substring(idx, idx + size)
}

/**
 * Extracts from a string the char sequence that occurs after the given subsequence.
 *
 * @param str the string
 * @param seq the subsequence to search
 * @return the extracted substring, or an empty string if the subsequence is not found
 */
fun String.afterSequence(seq: String): String {
    val idx = indexOf(seq) + seq.length
    if (idx == 0) {
        return ""
    }
    return substring(idx)
}
